<?php
/**
 * Created by PhpStorm.
 * User: kongjg
 * Date: 16/8/8
 * Time: 上午11:08
 */




class labels{
    private $fileName = 'test.txt';
    function getFileName (){
        return $this->fileName;
    }

    public function post($id,$title,$desc){
        $label = array(
            'l_id'=> $id,
            'l_title' => $title,
            'l_desc' => $desc,
        );

        $label_json = json_encode($label);
        if(file_exists($this->fileName)){
            file_put_contents($this->fileName,$label_json.PHP_EOL,FILE_APPEND);//PHP_EOL换行常量，通用
        }else{
            $file = fopen($this->fileName,'a+');
            fclose($file);
            $length =  file_put_contents($this->fileName,$label_json.PHP_EOL,FILE_APPEND);//PHP_EOL换行常量，通用
            if($length){
                echo 'success';
            }
        }


    }
    public function get($fileArray){
        return $this->label = $fileArray;
    }
    public function put(){

    }

    public function delete(){

    }

}

